home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 20.6 KB | 767 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPictur.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWPICTUR_H
- #include "FWPictur.h"
- #endif
-
- #ifndef FWGRGLOB_H
- #include "FWGrGlob.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- #ifndef FWGDEV_H
- #include "FWGDev.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- // ----- OS Includes -----
-
- #ifndef FWRESACC_H
- #include "FWResAcc.h"
- #endif
-
- #ifndef FWRESSIN_H
- #include "FWResSin.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWDEBUG_H
- #include "FWDebug.h"
- #endif
-
- #ifndef FWSTRMRW_H
- #include "FWStrmRW.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__RESOURCES__)
- #include <Resources.h>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Picture
- #endif
-
- FW_DEFINE_CLASS_M1(FW_PPicture, FW_CGraphicCountedPtr)
- FW_DEFINE_CLASS_M1(FW_CPictureRep, FW_CGraphicCountedPtrRep)
-
- FW_REGISTER_ARCHIVABLE_CLASS(FW_LPictureRep, FW_CPictureRep, FW_CPictureRep::Read, FW_CGraphicCountedPtrRep::Write)
-
- //========================================================================================
- // class FW_PPicture
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_PPicture::FW_PPicture
- //----------------------------------------------------------------------------------------
-
- FW_PPicture::FW_PPicture() :
- FW_CGraphicCountedPtr()
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PPicture::FW_PPicture
- //----------------------------------------------------------------------------------------
-
- FW_PPicture::FW_PPicture(FW_PlatformPict platformPict) :
- FW_CGraphicCountedPtr()
- {
- SetRep(new FW_CPictureRep(platformPict));
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PPicture::FW_PPicture
- //----------------------------------------------------------------------------------------
-
- FW_PPicture::FW_PPicture(FW_CResourceFile& resourceFile, FW_ResourceId resourceId) :
- FW_CGraphicCountedPtr()
- {
- SetRep(new FW_CPictureRep(resourceFile, resourceId));
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PPicture::FW_PPicture
- //----------------------------------------------------------------------------------------
-
- FW_PPicture::FW_PPicture(const FW_PPicture& other) :
- FW_CGraphicCountedPtr(other)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PPicture::~FW_PPicture
- //----------------------------------------------------------------------------------------
-
- FW_PPicture::~FW_PPicture()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PPicture::operator=
- //----------------------------------------------------------------------------------------
-
- FW_PPicture& FW_PPicture::operator=(const FW_PPicture& other)
- {
- // We don't need to test this == &other because SetRep will do it
- SetRep(other.GetRep());
- return *this;
- }
-
- //========================================================================================
- // CLASS FW_CPictureRep
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // Placeable (Aldus) metafile definitions for Windows
- //----------------------------------------------------------------------------------------
-
- #ifdef FW_BUILD_WIN
-
- #pragma pack(push,1)
-
- struct RECT16
- {
- short left;
- short top;
- short right;
- short bottom;
- };
-
- struct SAldusHeader
- {
- DWORD key;
- WORD hmf;
- RECT16 bbox;
- WORD inch;
- DWORD reserved;
- WORD checksum;
- } ;
-
- #pragma pack(pop)
-
- const DWORD kAldusKey = 0x9AC6CDD7l;
-
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::FW_CPictureRep
- //----------------------------------------------------------------------------------------
-
- FW_CPictureRep::FW_CPictureRep():
- #ifdef FW_BUILD_MAC
- fMacLockCount(0),
- #endif
- FW_CGraphicCountedPtrRep(),
- fPlatformPict(NULL),
- fOwnPicture(FALSE)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::FW_CPictureRep
- //----------------------------------------------------------------------------------------
-
- FW_CPictureRep::FW_CPictureRep(FW_CReadableStream& archive):
- #ifdef FW_BUILD_MAC
- fMacLockCount(0),
- #endif
- FW_CGraphicCountedPtrRep(),
- fPlatformPict(NULL),
- fOwnPicture(FALSE)
- {
- ReadFrom(archive);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::FW_CPictureRep
- //----------------------------------------------------------------------------------------
-
- FW_CPictureRep::FW_CPictureRep(FW_PlatformPict platformPict) :
- #ifdef FW_BUILD_MAC
- fMacLockCount(0),
- #endif
- FW_CGraphicCountedPtrRep(),
- fPlatformPict(platformPict),
- fOwnPicture(FALSE)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::FW_CPictureRep
- //----------------------------------------------------------------------------------------
-
- FW_CPictureRep::FW_CPictureRep(FW_CResourceFile& resourceFile, FW_ResourceId resourceId) :
- #ifdef FW_BUILD_MAC
- fMacLockCount(0),
- #endif
- FW_CGraphicCountedPtrRep(),
- fPlatformPict(NULL),
- fOwnPicture(FALSE)
- {
- LoadPictureFromResource(resourceFile, resourceId);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::~FW_CPictureRep
- //----------------------------------------------------------------------------------------
-
- FW_CPictureRep::~FW_CPictureRep()
- {
- DisposePlatformPict();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::DisposePlatformPict
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::DisposePlatformPict()
- {
- if (fOwnPicture && fPlatformPict != NULL)
- {
- #ifdef FW_BUILD_MAC
- ::KillPicture(fPlatformPict);
- #endif
- #ifdef FW_BUILD_WIN
- ::DeleteEnhMetaFile(fPlatformPict);
- #endif
- }
-
- fPlatformPict = NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::Copy
- //----------------------------------------------------------------------------------------
-
- FW_PPicture FW_CPictureRep::Copy() const
- {
- FW_ASSERT(fPlatformPict != NULL);
-
- FW_PlatformPict newHandle;
-
- #ifdef FW_BUILD_MAC
- newHandle = (FW_PlatformPict) FW_CMemoryManager::CopySystemHandle((FW_PlatformHandle)fPlatformPict);
- #endif
- #ifdef FW_BUILD_WIN
- newHandle = ::CopyEnhMetaFile(fPlatformPict, NULL);
- #endif
-
- return FW_PPicture(newHandle);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::OrphanPlatformPict
- //----------------------------------------------------------------------------------------
-
- FW_PlatformPict FW_CPictureRep::OrphanPlatformPict()
- {
- FW_ASSERT(fOwnPicture == TRUE); // Test first that we are the owner
- fOwnPicture = FALSE;
- return fPlatformPict;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::SetPlatformPict
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::SetPlatformPict(FW_PlatformPict newPict)
- {
- if (fPlatformPict != newPict)
- {
- DisposePlatformPict();
- fPlatformPict = newPict;
- }
-
- fOwnPicture = FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::AdoptPlatformPict
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::AdoptPlatformPict(FW_PlatformPict newPict)
- {
- SetPlatformPict(newPict);
- fOwnPicture = TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::LoadPictureFromResource
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::LoadPictureFromResource(FW_CResourceFile& resourceFile,
- FW_ResourceId resourceId)
- {
- #ifdef FW_BUILD_MAC
- FW_PlatformPict newPict =
- (FW_PlatformPict) resourceFile.PrivGetSpecialResource(resourceId, FW_kPicture);
- // Because of CFM we have to detach the resource
- ::DetachResource((Handle)newPict);
- AdoptPlatformPict(newPict);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CResource resource(resourceFile, resourceId, FW_kPicture);
- FW_CResourceSink sink(resource);
- FW_CReadableStream stream(&sink);
- ReadFrom(stream);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::Flatten(FW_CWritableStream& archive) const
- {
- WriteTo(archive);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::WriteTo
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::WriteTo(const FW_CWritableStream& stream) const
- {
- #ifdef FW_BUILD_MAC
- unsigned long picSize = FW_CMemoryManager::GetSystemHandleSize((FW_PlatformHandle)fPlatformPict);
- stream << picSize;
- FW_CPictureRep* self = (FW_CPictureRep*)this;
-
- self->MacLock();
-
- FW_TRY
- {
- stream.Write(*fPlatformPict, picSize);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- self->MacUnlock();
- FW_THROW_SAME();
- }
- FW_CATCH_END
-
- self->MacUnlock();
- #endif
-
- #ifdef FW_BUILD_WIN
- UINT bitsSize = ::GetEnhMetaFileBits(fPlatformPict, 0, NULL);
-
- BYTE* bitsBuf = new BYTE[bitsSize];
- ::GetEnhMetaFileBits(fPlatformPict, bitsSize, bitsBuf);
-
- stream.Write(bitsBuf, bitsSize);
-
- delete[] bitsBuf;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::ReadFrom
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::ReadFrom(const FW_CReadableStream& stream)
- {
- #ifdef FW_BUILD_MAC
- unsigned long picSize;
- stream >> picSize;
-
- fPlatformPict = (FW_PlatformPict) FW_CMemoryManager::AllocateSystemHandle(picSize);
-
- MacLock();
-
- FW_TRY
- {
- stream.Read(*fPlatformPict, picSize);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- MacUnlock();
- ::DisposeHandle((Handle)fPlatformPict);
- fPlatformPict = NULL;
- FW_THROW_SAME();
- }
- FW_CATCH_END
-
- MacUnlock();
- #endif
- #ifdef FW_BUILD_WIN
- HENHMETAFILE metafile = NULL;
-
- // Check if there is an Aldus metafile header
- SAldusHeader aldusHeader;
- stream.Read(&aldusHeader, sizeof(aldusHeader));
- if(aldusHeader.key == kAldusKey)
- {
- // ----- This is an Aldus format metafile
-
- // Read the header
- METAHEADER mfHeader;
- stream.Read(&mfHeader, sizeof(mfHeader));
-
- // Read the bits
- size_t bitsSize = mfHeader.mtSize * 2L;
- BYTE* bitsBuf = new BYTE[bitsSize];
- FW_CMemoryManager::CopyMemory(&mfHeader, bitsBuf, sizeof(mfHeader));
- stream.Read(bitsBuf + sizeof(mfHeader), bitsSize - sizeof(mfHeader));
-
- // Convert an Aldus (Win16) metafile to a Win32 Enhanced Metafile
- METAFILEPICT mfPict;
- mfPict.mm = MM_ANISOTROPIC;
- mfPict.xExt = (aldusHeader.bbox.right - aldusHeader.bbox.left) * 2540 / aldusHeader.inch;
- mfPict.yExt = (aldusHeader.bbox.bottom - aldusHeader.bbox.top) * 2540 / aldusHeader.inch;
-
- metafile = ::SetWinMetaFileBits(bitsSize, bitsBuf, NULL, &mfPict);
- delete[] bitsBuf;
- }
- else
- {
- // ----- Not an Aldus metafile, try Win32 Enhanced metafile
-
- // Read the header
- ENHMETAHEADER enhHeader;
- FW_CMemoryManager::CopyMemory(&aldusHeader, &enhHeader, sizeof(aldusHeader));
- stream.Read((char*) &enhHeader + sizeof(aldusHeader), sizeof(enhHeader) - sizeof(aldusHeader));
-
- // Verify the header
- if(enhHeader.iType == EMR_HEADER || enhHeader.nSize == sizeof(enhHeader))
- {
- // Read the bits
- size_t bitsSize = enhHeader.nBytes;
- BYTE* bitsBuf = new BYTE[bitsSize];
- FW_CMemoryManager::CopyMemory(&enhHeader, bitsBuf, sizeof(enhHeader));
- stream.Read(bitsBuf + sizeof(enhHeader), bitsSize - sizeof(enhHeader));
-
- // Create a metafile and set the bits
- metafile = ::SetEnhMetaFileBits(bitsSize, bitsBuf);
- delete[] bitsBuf;
- }
- }
-
- if(metafile == NULL)
- FW_Failure(FW_xInvalidPictureData);
-
- // Save metafile info
- AdoptPlatformPict(metafile);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::IsEqual
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CPictureRep::IsEqual(const FW_CGraphicCountedPtrRep* other) const
- {
- if (other == this)
- return TRUE;
-
- #ifdef FW_DEBUG
- FW_CPictureRep* pictureRep = FW_DYNAMIC_CAST(FW_CPictureRep, other);
- FW_ASSERT(pictureRep != NULL);
- #else
- FW_CPictureRep* pictureRep = (FW_CPictureRep*)other;
- #endif
-
- return fPlatformPict == pictureRep->fPlatformPict;
- }
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::MacLock
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::MacLock()
- {
- FW_ASSERT(fPlatformPict != NULL);
-
- if (fMacLockCount == 0)
- FW_CMemoryManager::LockSystemHandle((FW_PlatformHandle)fPlatformPict);
-
- fMacLockCount++;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::MacUnlock
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::MacUnlock()
- {
- FW_ASSERT(fPlatformPict != NULL);
- FW_ASSERT(fMacLockCount != 0);
-
- FW_CMemoryManager::UnlockSystemHandle((FW_PlatformHandle)fPlatformPict);
- fMacLockCount--;
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::GetPictBounds
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::GetPictBounds(FW_CRect& bounds) const
- {
- #ifdef FW_BUILD_MAC
- bounds.SetInt(
- 0,
- 0,
- (*fPlatformPict)->picFrame.right - (*fPlatformPict)->picFrame.left,
- (*fPlatformPict)->picFrame.bottom - (*fPlatformPict)->picFrame.top
- );
- #endif
-
- #ifdef FW_BUILD_WIN
- ENHMETAHEADER emh;
- ::GetEnhMetaFileHeader(fPlatformPict, sizeof(emh), &emh);
-
- // emh.rclBounds is the bounding rectangle in pixels, computed by GDI
-
- bounds.SetInt(
- emh.rclBounds.left,
- emh.rclBounds.top,
- emh.rclBounds.right,
- emh.rclBounds.bottom
- );
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::GetPictBounds
- //----------------------------------------------------------------------------------------
-
- void FW_CPictureRep::GetPictBounds(FW_CGraphicContext& gc, FW_CRect& bounds) const
- {
- #ifdef FW_BUILD_MAC
- FW_CPoint size = gc.DeviceToLogical(
- (*fPlatformPict)->picFrame.right - (*fPlatformPict)->picFrame.left,
- (*fPlatformPict)->picFrame.bottom - (*fPlatformPict)->picFrame.top
- );
- bounds.Set(FW_IntToFixed(0), FW_IntToFixed(0), size.x, size.y);
- #endif
-
- #ifdef FW_BUILD_WIN
- ENHMETAHEADER emh;
- ::GetEnhMetaFileHeader(fPlatformPict, sizeof(emh), &emh);
-
- // emh.rclFrame is the bounding rectangle as specified by the creator, in 0.01 mm units
-
- FW_CGraphicDevice* device = gc.GetGraphicDevice();
- HDC hDC = *device;
-
- int xRes = ::GetDeviceCaps(hDC, LOGPIXELSX);
- int yRes = ::GetDeviceCaps(hDC, LOGPIXELSY);
-
- FW_SPlatformRect plfmBounds;
-
- plfmBounds.left = emh.rclFrame.left * xRes / 2540;
- plfmBounds.top = emh.rclFrame.top * yRes / 2540;
- plfmBounds.right = emh.rclFrame.right * xRes / 2540;
- plfmBounds.bottom = emh.rclFrame.bottom * yRes / 2540;
-
- bounds = gc.DeviceToLogical(plfmBounds);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::Read
- //----------------------------------------------------------------------------------------
-
- void* FW_CPictureRep::Read(FW_CReadableStream& archive)
- {
- return new FW_CPictureRep(archive);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::GetPlatformPict
- //----------------------------------------------------------------------------------------
-
- FW_PlatformPict FW_CPictureRep::GetPlatformPict() const
- {
- return fPlatformPict;
- }
-
- //========================================================================================
- // class FW_CPictureContext
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureContext::FW_CPictureContext
- //----------------------------------------------------------------------------------------
-
- FW_CPictureContext::FW_CPictureContext(Environment* ev,
- FW_PPicture& picture,
- FW_CFixed xSize,
- FW_CFixed ySize) :
- FW_CGraphicContext(ev),
- #ifdef FW_BUILD_MAC
- fMacPictHandle(NULL),
- #endif
- fPicture(picture),
- fGraphicDevice(NULL)
- {
- ODPlatformCanvas platformCanvas;
-
- FW_CRect clipRect;
-
- #ifdef FW_BUILD_MAC
- platformCanvas = FW_gScratchWindow;
- clipRect.Set(FW_IntToFixed(0), FW_IntToFixed(0), xSize, ySize);
- #endif
-
- #ifdef FW_BUILD_WIN
- HDC hDCRef = ::GetDC(NULL);
-
- int xRes = ::GetDeviceCaps(hDCRef, LOGPIXELSX);
- int yRes = ::GetDeviceCaps(hDCRef, LOGPIXELSY);
-
- int xDevMM = ::GetDeviceCaps(hDCRef, HORZSIZE);
- int yDevMM = ::GetDeviceCaps(hDCRef, VERTSIZE);
- int xDevPix = ::GetDeviceCaps(hDCRef, HORZRES);
- int yDevPix = ::GetDeviceCaps(hDCRef, VERTRES);
-
- // The size comes in at 72dpi: convert to HiMetric units (0.01 mm)
- FW_SPlatformRect boundsMM(0, 0, xSize.AsInt() * 2540 / 72, ySize.AsInt() * 2540 / 72);
-
- platformCanvas = ::CreateEnhMetaFile(hDCRef, NULL, &boundsMM, NULL);
-
- // Convert size to pixels, for use in the coordinate system
- FW_CFixed fx72 = FW_IntToFixed(72);
-
- int xSizePix =
- (FW_WideMultiply(xSize, FW_IntToFixed(xRes)) / fx72).AsInt();
- // FixedToInt(::FW_FixMul(xSize, ::FW_FixDiv(IntToFixed(xRes), IntToFixed(72))));
-
- int ySizePix =
- (FW_WideMultiply(ySize, FW_IntToFixed(yRes)) / fx72).AsInt();
- // FixedToInt(::FW_FixMul(ySize, ::FW_FixDiv(IntToFixed(yRes), IntToFixed(72))));
-
- int xDraw = (254 * xSizePix * xDevPix) / (100 * xDevMM);
- int yDraw = (254 * ySizePix * yDevPix) / (100 * yDevMM);
-
- clipRect.SetInt(0, 0, xDraw, yDraw);
-
- ::ReleaseDC(NULL, hDCRef);
- #endif
-
- fGraphicDevice = new FW_CGraphicDevice(ev, platformCanvas);
-
- #ifdef FW_BUILD_WIN
- // Set the resolution: (xSize, ySize) should map to (xDraw, yDraw)
- FW_CPoint deviceResoltion(
- xSize / FW_IntToFixed(xDraw),
- ySize / FW_IntToFixed(yDraw));
- fGraphicDevice->SetResolution(deviceResoltion);
- #endif
-
- FW_CAcquiredODShape aqClipShape = ::FW_NewODShape(ev, clipRect);
-
- InitGraphicContext(fGraphicDevice,
- NULL,
- aqClipShape);
-
- #ifdef FW_BUILD_MAC
- FW_SPlatformRect plfmBounds(0, 0, xSize.AsInt(), ySize.AsInt());
-
- ::PortSize(plfmBounds.right, plfmBounds.bottom);
- fMacPictHandle = ::OpenPicture(&plfmBounds);
- #endif
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureContext::~FW_CPictureContext
- //----------------------------------------------------------------------------------------
-
- FW_CPictureContext::~FW_CPictureContext()
- {
- FW_START_DESTRUCTOR
-
- FW_PlatformPict newPict;
-
- #ifdef FW_BUILD_MAC
- ::ClosePicture();
- newPict = fMacPictHandle;
- #endif
-
- // ----- Terminate the superclass
- TerminateGraphicContext();
-
- #ifdef FW_BUILD_WIN
- HDC hDC = fGraphicDevice->GetPlatformCanvas();
- newPict = ::CloseEnhMetaFile(hDC);
- #endif
-
- // ----- Delete the device
- fGraphicDevice->Release();
-
- // ----- Store the result in the picture
- fPicture = FW_PPicture(newPict);
- }
-